// 电视机（接收者）
class TV {
    turnOn() {
        console.log('打开电视');
    }
    
    turnOff() {
        console.log('关闭电视');
    }
}

// 命令类
class TurnOnCommand {
    constructor(tv) {
        this.tv = tv;
    }
    
    execute() {
        this.tv.turnOn();
    }
}

class TurnOffCommand {
    constructor(tv) {
        this.tv = tv;
    }
    
    execute() {
        this.tv.turnOff();
    }
}

// 遥控器（调用者）
class RemoteControl {
    constructor() {
        this.command = null;
    }
    
    setCommand(command) {
        this.command = command;
    }
    
    pressButton() {
        this.command.execute();
    }
}

export { TV, TurnOnCommand, TurnOffCommand, RemoteControl }; 